#pragma once

#include "LiteralUnlimitedNatural.h"


namespace uml {

const int LiteralUnlimitedNatural::value_default_ = 0;
LiteralUnlimitedNatural::LiteralUnlimitedNatural(const QString& umlType)
    : LiteralSpecification(umlType) {}

void LiteralUnlimitedNatural::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    LiteralSpecification::fromJson(json, errorList);
    value_ = json.value("value").toInt(value_default_);
}

void LiteralUnlimitedNatural::toJson(QJsonObject& json) {
    LiteralSpecification::toJson(json);
    if (value_ != value_default_) {
        json.insert("value", value_);
    }
}

/// <summary>
/// isComputable
    /// The query isComputable() is redefined to be true.
/// </summary>
    /// <code>
    /// result = (true)
    /// </code>
bool LiteralUnlimitedNatural::isComputable() const
{
    return false;
}

/// <summary>
/// unlimitedValue
    /// The query unlimitedValue() gives the value.
/// </summary>
    /// <code>
    /// result = (value)
    /// </code>
int LiteralUnlimitedNatural::unlimitedValue() const
{
    return 0;
}

/// <summary>
/// value getter
/// The specified UnlimitedNatural value.
/// </summary>
int LiteralUnlimitedNatural::value() const {
    return value_;
}

/// <summary>
/// value setter
/// The specified UnlimitedNatural value.
/// </summary>
void LiteralUnlimitedNatural::setValue(int value) {
    value_ = value;
}

} // namespace uml
